﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="fhdb" content="true">
    <title>充值保证金</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/rechargebond.css">
    <link rel="stylesheet" href="../shop/css/Navigation.css">
    <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div class="backBox" onClick="javascript:history.back(-1);">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </div>
    <div class="topTitle">
        充值保证金
    </div>
    <div class="userNumber">
        <input type="text" class="form-control tbnumber" placeholder="请输入充值金额" onkeyup="clearNoNum(this)">
        <button type="button" class="btn btn-danger">充值</button>
    </div>
    <table class="table table-bordered" style="margin-top:70px;">
        <tr>
            <th>序号</th>
            <th>充值金额</th>
            <th>可购买数量</th>
        </tr>
        <tbody id="bzjbody">

        </tbody>
    </table>
</body>
</html>
<script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "../../BaseRefWeb.aspx?stype=ISpBondmanageFun&method=GetBzjList&type=sp",
            success: function (result) {
                var data = JSON.parse(result);
                if (data.msg == "_timeout") {
                    window.location.href = "../UserLogin/Login.html";
                }
                else {
                    var html = "";
                    for (var i = 0; i < data.length; i++) {
                        var num = i + 1;
                        html += '<tr>';
                        html += '<td>' + num + '</td><td>' + data[i].TB_BZJ_PRICE + '元</td><td>' + data[i].TB_BZJ_COUNT + '幅</td>';
                        html += '</tr>';
                    }
                    $("#bzjbody").empty();
                    $("#bzjbody").append(html);
                }
            }
        });
        $(".btn-danger").click(function () {
            if (Number($(".tbnumber").val()) < 50) {
                alert("充值金额不得小于50");
                return;
            }
            window.location = "../../BaseRefWeb.aspx?stype=ISpOrderFun&method=GetBzjZhifu&type=sp&TB_BZJ_PRICE=" + $(".tbnumber").val()+"";
            //$.ajax({
            //    type: "POST",
            //    data: { TB_BZJ_PRICE: $(".tbnumber").val() },
            //    url: "../../BaseRefWeb.aspx?stype=ISpBondmanageFun&method=DoAddBond&type=sp",
            //    success: function (result) {
            //        var data = JSON.parse(result);
            //        if (data.msg == "_timeout") {
            //            window.location.href = "../UserLogin/Login.html";
            //        }
            //        else {
            //            window.location.href = 'mybond.html';
            //        }
            //    }
            //});
        })
    })
    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符
        obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
        obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');//只能输入两个小数
        if (obj.value.indexOf(".") < 0 && obj.value != "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
            obj.value = parseFloat(obj.value);
        }
    }
</script>